from typing import List

from infirmary_admin_src.infirmary_common.infirmary_controller import IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends, Path, Body

from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.department.services import DepartmentBusinesses




class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''
    department_id: int = Body(None, alias='departmentId', title="departmentId", description='department_id')
    department_code: str = Body(None, alias='departmentCode', title="departmentId", description='department_id')
    manager_id: int = Body(None, alias='managerId', title="managerId", description='manager_id')
    name: str = Body(None, alias='name', title="name", description='name')
    parent_id: int = Body(0, alias='parentId', title="parent_id", description='parent_id')
    sort: int = Body(0, alias='sort', title="sort", description='sort')
    update_time: str = Body(None, alias='updateTime', title="updateTime", description='loginName')



class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 schema_param: XParam,
                 ):
        super().__init__(request=request)
        # 入参参数
        # 入参参数
        self.schema_param = schema_param


@RestControllerWithDepends()
class SystemDepartmentUpdateController(IController):

    def business_login(self):
        pass
        result = DepartmentBusinesses.edit_sys_dpartment_info(department_id=self.schema_param.department_id,
                                                     **self.schema_param.dict(exclude={'department_id'}))
        if result:
            self.response_msg = '更新成功'
        else:
            self.response_ok = False
            self.response_msg = '更新失败'
            return None

        return None
